package com.dajiba.demo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

public class CustomFillBg extends BaseCustomView {

    public CustomFillBg(Context context) {
        super(context);
        setBackgroundColor(Color.BLUE);
    }

    public CustomFillBg(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomFillBg(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Path path = new Path();
        path.addRect(new RectF(getLeft(), getTop(), getRight(), getBottom()), Path.Direction.CW);
        path.addRoundRect(new RectF(100, 200, 300, 400), 10, 10, Path.Direction.CW);
        path.setFillType(Path.FillType.EVEN_ODD);
        canvas.drawPath(path, mPaint);
    }
}
